using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SampleCrashApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // unhandled exception
            int a = 99;
            int b = 0;
            int c = (a / b);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // correctly handle the exception
            try
            {
                int a = 99;
                int b = 0;
                int c = (a / b);
            }
            catch (DivideByZeroException) 
            {
                MessageBox.Show("Cannot divide by zero, but you knew that!");
            }
        }
    }
}